package com.boot.security.server.service.impl.mffl.MfflLawyerComment;

import com.boot.security.server.dao.mffl.MfflLawyerCommentDao;
import com.boot.security.server.model.mffl.MfflLawyerComment;
import com.boot.security.server.utils.mffl.ReturnBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Service
public class MfflLawyerCommentService {

    @Autowired
    MfflLawyerCommentDao mffllawyercommentDao;
    /**
     * 用户评论律师表
     * @param content 内容
     * @param rank  评分
     * @param userid  用户id
     * @param Lawyerid  律师id
     * @param typeid  类型名字
     * @return
     */
    @Transactional
    public ReturnBean LawyerComment(String content,Integer rank,Integer userid,Integer Lawyerid,Integer typeid){
        ReturnBean returnBean = new ReturnBean();
        //新增律师评论
        try{
            MfflLawyerComment mlc  = new MfflLawyerComment();
            mlc.setRank(rank);
            mlc.setContent(content);
            mlc.setUserId(userid);
            mlc.setLawyerId(Lawyerid);
            mlc.setType(typeid);
            Date date = new Date();
            mlc.setCreateTIme(date);
            mlc.setUpdateTime(date);
            mffllawyercommentDao.save(mlc);
        }catch(Exception e){
            e.printStackTrace();
            returnBean.setReturnBean("105");
            return returnBean;
        }
        return returnBean;
    }
}
